import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

public class MenuFrame extends Frame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4156494860703412270L;
	private MyCanvas can;

	MenuFrame(MyCanvas c){
		super("Menu");
		can = c;
		setLocation(240,200);
		setSize(50, 220);
		setResizable(true);
		setLayout(new BorderLayout());
		
		Button clear = new Button("Clear");
		Button exit = new Button("Exit");
		Button draw = new Button("Draw");
		
		exit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				System.exit(0);
			}

		});
		clear.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				can.clear();
			}

		});
		draw.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Random ra = new Random();
				if(ra.nextBoolean()){
					can.drawSquare(ra.nextInt(can.getWidth()/2), ra.nextInt(can.getHeight()/2), ra.nextInt(can.getHeight()), new Color(ra.nextInt(255),ra.nextInt(255),ra.nextInt(255)));
				}
				else{
					can.drawCircle(ra.nextInt(can.getWidth()/2), ra.nextInt(can.getHeight()/2), ra.nextInt(can.getHeight()), new Color(ra.nextInt(255),ra.nextInt(255),ra.nextInt(255)));
				}	
			}		

		});

		add(clear, BorderLayout.NORTH);
		add(draw, BorderLayout.CENTER);
		add(exit, BorderLayout.SOUTH);

		setVisible(true);
	}





}
